
<template tag="以下文档内容为hycli自动生成">
  <el-dialog
    v-model="conf.visible"
    v-if="conf.visible" 
    :title="title"
   :width="conf.width"
    draggable
      align-center="true" 
    :close-on-click-modal="false"
  >
  <el-form :model="form"  ref="form" :rules="rules_aaafg">
    <el-row>
    <el-col :span="12">
    <!-- {"index":85,"raw":"plan_id","name":"plan_id","cname":"PlanId","type":{"raw":"number(10)","name":"number","len":10,"dlen":0},"defValue":"0","allowNull":true,"constraints":["le","c","bq","sl(dev_plan,-,#lob_id)","u","v","tp(readonly,u)"],"desc":{"raw":"研发计划","name":"研发计划"}} -->
     <!--研发计划 下拉控件 -->
    <el-form-item prop="plan_id" label="研发计划" label-width="100px" label-position="right">
      <el-select   v-model="form.plan_id" style="width: 100%" filterable clearable
        placeholder="请选择研发计划" >
        <el-option v-for="item in plan_idList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":87,"raw":"priority","name":"priority","cname":"Priority","type":{"raw":"number(1)","name":"number","len":1,"dlen":0},"defValue":"0","allowNull":false,"constraints":["l","c","u","v","sl(PRI)","lw(60)","le","q","tp(radio,c-u)","tp(tag,l)","cidx(102)","uidx(102)"],"desc":{"raw":"优先级","name":"优先级"}} -->
    <el-form-item prop="priority" label="优先级" label-width="100px" label-position="right">
      <el-radio-group v-model="form.priority"   >
        <el-radio-button v-for="item in priorityList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":86,"raw":"name","name":"name","cname":"Name","type":{"raw":"varchar2(48)","name":"varchar2","len":48,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","u","q","v","DN","rows(1)","lw(160)","#like"],"desc":{"raw":"名称","name":"名称"}} -->
    <!--名称 输入控件 -->
    <el-form-item prop="name" label="名称" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.name"  maxlength="48" 
      :rows="1"  placeholder="请输入名称"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":88,"raw":"daily_tp","name":"daily_tp","cname":"DailyTp","type":{"raw":"number(1)","name":"number","len":1,"dlen":0},"defValue":"0","allowNull":false,"constraints":["l","le","q","sl(ops_tp)","c","u","v","tp(radio,c-u)"],"desc":{"raw":"任务类型","name":"任务类型"}} -->
    <el-form-item prop="daily_tp" label="任务类型" label-width="100px" label-position="right">
      <el-radio-group v-model="form.daily_tp"   >
        <el-radio-button v-for="item in daily_tpList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":89,"raw":"dtstatus","name":"dtstatus","cname":"Dtstatus","type":{"raw":"number(2)","name":"number","len":2,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","sl","q","c","u","v","tp(radio,c-u)","tp(tag,l)"],"desc":{"raw":"状态","name":"状态"}} -->
    <el-form-item prop="dtstatus" label="状态" label-width="100px" label-position="right">
      <el-radio-group v-model="form.dtstatus"   >
        <el-radio-button v-for="item in dtstatusList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":92,"raw":"content","name":"content","cname":"Content","type":{"raw":"varchar2(2000)","name":"varchar2","len":2000,"dlen":0},"defValue":"","allowNull":false,"constraints":["le","c","q","u","v","rows(8)","#like"],"desc":{"raw":"内容","name":"内容"}} -->
    <!--内容 输入控件 -->
    <el-form-item prop="content" label="内容" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.content"  maxlength="2000" 
      :rows="8"  type="textarea" show-word-limit  placeholder="请输入内容"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":93,"raw":"master","name":"master","cname":"Master","type":{"raw":"number(8)","name":"number","len":8,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","q","sl(dmaster,5,#lob_id)","q","c","u","v","tp(radio,c-u)"],"desc":{"raw":"负责人","name":"负责人"}} -->
    <el-form-item prop="master" label="负责人" label-width="100px" label-position="right">
      <el-radio-group v-model="form.master"   >
        <el-radio-button v-for="item in masterList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":94,"raw":"collaborators","name":"collaborators","cname":"Collaborators","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":true,"constraints":["le","c","u","v","sl(nmaster,-,#lob_id)","tp(radio,c-u)"],"desc":{"raw":"协作人员","name":"协作人员"}} -->
    <el-form-item prop="collaborators" label="协作人员" label-width="100px" label-position="right">
      <el-radio-group v-model="form.collaborators"   >
        <el-radio-button v-for="item in collaboratorsList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":95,"raw":"sponsor","name":"sponsor","cname":"Sponsor","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":true,"constraints":["le","c","u","v"],"desc":{"raw":"发起人","name":"发起人"}} -->
    <!--发起人 输入控件 -->
    <el-form-item prop="sponsor" label="发起人" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.sponsor"  maxlength="32" 
      :rows="0"  placeholder="请输入发起人"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":96,"raw":"finish_time","name":"finish_time","cname":"FinishTime","type":{"raw":"date","name":"date","len":0,"dlen":0},"defValue":"","allowNull":true,"constraints":["l","le","c","u","q","tp(daterange,q)","f(MM/dd)","tp(datetime,c-u,yyyy/MM/dd 18:00:00)","v"],"desc":{"raw":"完成时间","name":"完成时间"}} -->
    <!--完成时间 日期控件 -->
    <el-form-item prop="finish_time" label="完成时间" label-width="100px" label-position="right">
      <el-date-picker style="width: 100%" v-model="form.finish_time" clearable type="datetime"
        placeholder="请选择完成时间" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" 
         :default-time="new Date($theia.str.dateFormat(new Date(),'yyyy/MM/dd 18:00:00'))"/>
    </el-form-item>
    </el-col>
    </el-row>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide" icon="close">取消</el-button>
        <el-button type="primary" @click="save" icon="select">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import rtext from "@/views/cmpnts/rtext.vue"
export default {
  components: {
    rtext
},
  data() {
    return {
      conf: {
        title:"运维事务",
        visible: false,
        width:"60%",
        uploadPath:this.$theia.env.join("/file/upload"),
      },
rules_aaafg:{
    plan_id:[{required:false,message:"请输入研发计划",trigger: 'blur'}],
    priority:[{required:true,message:"请输入优先级",trigger: 'blur'}],
    name:[{required:true,message:"请输入名称",trigger: 'blur'}],
    daily_tp:[{required:true,message:"请输入任务类型",trigger: 'blur'}],
    dtstatus:[{required:true,message:"请输入状态",trigger: 'blur'}],
    content:[{required:true,message:"请输入内容",trigger: 'blur'}],
    master:[{required:true,message:"请输入负责人",trigger: 'blur'}],
    collaborators:[{required:false,message:"请输入协作人员",trigger: 'blur'}],
    sponsor:[{required:false,message:"请输入发起人",trigger: 'blur'}],
    finish_time:[{required:false,message:"请输入完成时间",trigger: 'blur'}],
  },
    form:{
        plan_id:"",
        priority:"",
        name:"",
        daily_tp:"",
        dtstatus:"",
        content:"",
        master:"",
        collaborators:"",
        sponsor:"",
        finish_time:"",
    },
    plan_idList:[],
    priorityList:[],
    daily_tpList:[],
    dtstatusList:[],
    masterList:[],
    collaboratorsList:[],
    }
  },
  methods: {
    show(fm = {}) {
      this.title = fm.$title || this.title
      this.conf.visible = true;
      this.loadEnums_aaafg()
      let local = {}
      let cache = Object.assign(local,fm)
      this.form = Object.assign(cache,this.$route.params)
    },
    save(){
      this.$refs.form.validate((v=>{
          if(v) this.onSave()
      }))
    },
    onSave(){
        let that = this
        let postForm = Object.assign({},this.form)
        postForm.lob_id = this.$theia.user.get("lob_id")
        //保存数据
        this.$theia.http.post("/ws/ops/task",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '运维事务保存成功',duration:5000})
            that.hide()
            that.$theia.enum.clear("ops_task")
            that.$emit("onsaved")
        }).catch(res=>{
            let code = ((res||{}).response||{}).status||0
            let msg= `运维事务保存失败(${code})`
            msg = code == 909? msg+"数据重复，请修改后重试":msg
            that.$notify.error({title: '失败',message:msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
    onUploadSuccess(response){
    },
    loadEnums_aaafg(){
        //研发计划
        this.plan_idList = this.$theia.enum.get("dev_plan","",this.$theia.user.get("lob_id"),false,"")
        //优先级
        this.priorityList = this.$theia.enum.get("PRI","","" ,false,"")
        //任务类型
        this.daily_tpList = this.$theia.enum.get("ops_tp","","" ,false,"")
        //状态
        this.dtstatusList = this.$theia.enum.get("dtstatus","","" ,false,"")
        //负责人
        this.masterList = this.$theia.enum.get("dmaster","5",this.$theia.user.get("lob_id"),false,"")
        //协作人员
        this.collaboratorsList = this.$theia.enum.get("nmaster","",this.$theia.user.get("lob_id"),false,"")
    },

},
}
</script>

<style scoped>
.avatar-uploader .avatar {
  width: 80px;
  height: 80px;
  display: block;
}
.form_item_info{
  margin-left: 4px;
  color:#999;
}
.form_item_info:hover{
  cursor: pointer;
  font-weight: 500;
  color:#333;
}
</style>